import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { resolve } from "path";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
import AutoImport from "unplugin-auto-import/vite";

export default defineConfig({
  plugins: [
    vue(),
    Components({
      // 组件目录，默认为 src/components
      dirs: ["src/components"],
      // 组件的有效扩展名
      extensions: ["vue"],
      // 配置需要自动导入的组件库
      resolvers: [ElementPlusResolver()],
      // 生成自动导入的类型声明文件
      dts: "src/components.d.ts",
    }),
    AutoImport({
      imports: ["vue", "vue-router", "pinia"],
      dts: "src/auto-imports.d.ts",
      eslintrc: {
        enabled: true,
      },
    }),
  ],
  resolve: {
    alias: {
      "@": resolve(__dirname, "./src"),
    },
  },
});
